package model
{
	import com.adobe.cairngorm.CairngormError;
	import com.adobe.cairngorm.CairngormMessageCodes;
	
	import flash.utils.Dictionary;
	
	public class WhoDataModelLocator
	{
		private static var instance:WhoDataModelLocator;
		public static var WFA_BOYS:String = "wfa_boys";
		public static var WFA_GIRLS:String = "wfa_girls";
		public static var LHFA_BOYS:String = "lhfa_boys";
		public static var LHFA_GIRLS:String = "lhfa_girls";
		public static var HCFA_BOYS:String = "hcfa_boys";
		public static var HCFA_GIRLS:String = "hcfa_girls";
		
		public var wfa_boys:Dictionary;
    	public var wfa_girls:Dictionary;
		public var lhfa_girls:Dictionary;
		public var lhfa_boys:Dictionary;
		public var hcfa_girls:Dictionary;
    	public var hcfa_boys:Dictionary;
    	
    	public function WhoDataModelLocator() {
			if (instance != null) {
				throw new CairngormError(CairngormMessageCodes.SINGLETON_EXCEPTION, "WhoDataModelLocator");
			}
			instance = this;
		}

		public static function getInstance():WhoDataModelLocator {
			if (instance == null) {
				instance = new WhoDataModelLocator();
				instance.reset();
			}
			return instance;
		}
		
		public function reset():void {
			wfa_boys = new Dictionary();
			wfa_girls = new Dictionary();
			lhfa_boys = new Dictionary();
			lhfa_girls = new Dictionary();
			hcfa_boys = new Dictionary();
			hcfa_girls = new Dictionary();
		}
		
		public function getDataMap(name:String):Dictionary {
			if (name == WFA_BOYS) return wfa_boys;
			if (name == WFA_GIRLS) return wfa_girls;
			if (name == HCFA_BOYS) return hcfa_boys;
			if (name == HCFA_GIRLS) return hcfa_girls;
			if (name == LHFA_BOYS) return lhfa_boys;
			if (name == LHFA_GIRLS) return lhfa_girls;
			throw new CairngormError("passed in string " + name + " is not recognizable");
		}
		
		public function getServiceName(name:String):String {
			if (name == WFA_BOYS) return "load_wfa_boys";
			if (name == WFA_GIRLS) return "load_wfa_girls";
			if (name == HCFA_BOYS) return "load_hcfa_boys";
			if (name == HCFA_GIRLS) return "load_hcfa_girls";
			if (name == LHFA_BOYS) return "load_lhfa_boys";
			if (name == LHFA_GIRLS) return "load_lhfa_girls";
			throw new CairngormError("passed in string " + name + " does not match any known service");
		}
	}
}